import sys

class Solution(object):
    def maxProfit(self, prices):
        """
        :type prices: List[int]
        :rtype: int
        """
        minBefore = sys.maxsize
        maxProfit = 0
        for price in prices:
            if price > minBefore:
                profit = price - minBefore
                maxProfit = max(maxProfit, profit)
            minBefore = min(minBefore, price)
        return maxProfit